<?php

namespace App\Http\Controllers\Admin;

use App\Http\Model\Device;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Crypt;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

class DeviceController extends Controller
{
    /**
     * 设备列表页面
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        $device=new Device();
        $device_list=$device::where('device_user_id',session('user_id'))->with('belongsToCate')->get();
        return view('admin.device',['device_list'=>$device_list]);
    }

    /**
     * 设备二维码生成
     * @param Request $request
     * @return mixed
     */
    public function qrCode(Request $request)
    {
       return QrCode::format('png')->size(200)->generate(Crypt::encryptString($request->device_id));
        
    }
}
